<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>页面电子时钟</title>
    <style>
        p {
            font-size: 50px;
            font-weight: 25px;
        }
    </style>
    <p id="clock">在这里显示电子时钟</p>

</head>

<body>
    <script>
        function showTime() {
            var now = new Date();
            var year = now.getFullYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();
            var hour = now.getHours();
            var minute = now.getMinutes();
            var seconds = now.getSeconds();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (date >= 0 && date <= 9) {
                date = "0" + date;
            }
            if (minute >= 0 && minute <= 9) {
                minute = "0" + minute;
            }
            if (hour >= 0 && hour <= 9) {
                hour = "0" + hour;
            }
            if (seconds >= 0 && seconds <= 9) {
                seconds = "0" + seconds;
            }
            var time_text = year + '年' + month + '月' + date + '日' +
                hour + ':' + minute + ':' + seconds;
            var clock_line = document.getElementById("clock");
            clock_line.innerText = time_text;
            setTimeout("showTime();", 1000);
        }
        showTime();
    </script>
</body>

</html>